Conversation
|
Claude finished @thswansonfxg's task in 2m 23s —— View job SummaryThis PR adds a new The PR addresses the issues raised by Cursor Bugbot in earlier reviews:
BlockersNone Suggestions1. PR description should use "Fixes:" format for Linear linkThe Linear issue link at the bottom of the PR description should use the 2. Docs section is emptyThe PR template asks for documentation updates or a tracking ticket. Since this adds a user-facing schema field, consider:
3. Consider adding a test for the C FFI optional enum round-tripThe Rust serde tests ( point_style: unsafe { self.point_style.as_ref() }.map(|&v| v as i32),But an integration test would catch regressions if the generator changes. 4. Test fixture update is good, but snapshot diffs are noisyThe test fixtures now include 5. Minor:
|
…te-to-control-point-shape-in-locationfix
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
…ring deserialization
jtbandes
left a comment
There was a problem hiding this comment.
This feels like a good direction, I'm just not sure if I have quite enough expertise on the Rust and C++ (particularly Arena) side of things to give a definitive stamp 😬
| /// | ||
| /// Uses string names for human-readable formats (JSON) and i32 for binary formats. | ||
| #[cfg(feature = "serde")] | ||
| macro_rules! serde_enum_mod_optional { |
There was a problem hiding this comment.
@eloff @ericmlujan could you folks review this part? I'm not familiar with this code at all and @gasmith is out -- I do wonder if there's a way we could combine this with the non-optional macro rather than having two whole macros for it? but not sure how feasible that suggestion is
There was a problem hiding this comment.
I'm certainly not confident enough in Rust macros to combine them nicely, especially for SDK level code. This was done because it was easier for me to understand and easier for me to read.
Super happy to change this if someone better at rust has some ideas.
| return `${fieldName}: self.${fieldName}`; | ||
| case "enum": | ||
| if (field.optional) { | ||
| return `${fieldName}: unsafe { self.${fieldName}.as_ref() }.map(|&v| v as i32)`; |
There was a problem hiding this comment.
is this actually unsafe? I think this is for someone who knows more Rust than me to answer
There was a problem hiding this comment.
I think yes because self.point_style is a *const FoxglovePointStyle — a raw pointer in the C FFI struct.
But we also talked about this in person. Someone who knows rust better might need to stamp this.
| case "enum": | ||
| if (field.optional) { | ||
| const cEnumType = `foxglove_${toSnakeCase(field.type.enum.name)}`; | ||
| return `if (src.${srcName}) { auto* ptr = arena.alloc<${cEnumType}>(1); *ptr = static_cast<${cEnumType}>(*src.${srcName}); dest.${dstName} = ptr; } else { dest.${dstName} = nullptr; }`; |
There was a problem hiding this comment.
I am wondering if this whole thing could possibly be replaced with dest.${dstName} = reinterpret_cast<const ${cEnumType}*>(src.${srcName})?
I'm not sure if that would actually work or be safe - it just came to mind since the generated code looked a bit complicated and I think these types are compatible.
If that doesn't work, it might be nice to actually put some line breaks in this string so it's more readable here (though it does get auto-formatted in the generated files)
There was a problem hiding this comment.
That was implemented because of this cursor comment here: #870 (comment)
Further reading says that maybe its totally safe? I am happy to change this, but its being flagged because of garbage bytes and the potential of undefined behavior
There was a problem hiding this comment.
ah ok, I missed that the sizes are different, I guess that makes sense
| name: "PointStyle", | ||
| description: "Style of point used for map visualization", | ||
| parentSchemaName: "LocationFix", | ||
| protobufEnumName: "PointStyle", |
There was a problem hiding this comment.
I wonder if we should do something like
| name: "PointStyle", | |
| description: "Style of point used for map visualization", | |
| parentSchemaName: "LocationFix", | |
| protobufEnumName: "PointStyle", | |
| name: "MapPointStyle", //(or LocationFixPointStyle?) | |
| description: "Style of point used for map visualization", | |
| parentSchemaName: "LocationFix", | |
| protobufEnumName: "PointStyle", |
?
Although it's also making me realize that what is currently called "protobufEnumName" should maybe be used for any language where we nest enums inside the schemas (which it seems includes c++ too)...
There was a problem hiding this comment.
I think we want to have PointStyle as eventually the goal might be to have these point styles shared across a few different panels. I agree that maybe we need to update protobufEnumName to just be enumName. Also happy to make those changes
Changelog
Add point_style optional enum field to LocationFix schema, allowing users to customize the marker style (dot, diamond, square, plus, cross, pin) when visualizing locations on a map.
Docs
The generated schemas/README.md includes the new PointStyle enum and point_style field documentation. No additional docs PR is needed.
Description
This PR adds a new PointStyle enum and optional point_style field to the LocationFix schema across all SDK bindings (Rust,
Python, C++, C, TypeScript, ROS, Protobuf, FlatBuffer, JSON Schema, OMG IDL).
Changes:
https://linear.app/foxglove/issue/ERT-1612/add-optional-attribute-to-control-point-shape-in-locationfix-messages